﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lab_se_4
{
    class present
    {
        
        public List<sweet> ListOfSweets;
        public int total_price;

        public present(int weight, bool cacao, bool milk, bool wafle, bool sand)
        {
            /*
            Random rand = new Random();
            Candies = rand.Next(1, 5);
             * */
            int Candies = 0;
            if (cacao == true) Candies++;
            if (milk == true) Candies++;
            if (wafle == true) Candies++;
            if (sand == true) Candies++;
            ListOfSweets = new List<sweet>(Candies);
            сreate_present(weight, Candies, cacao, milk, wafle, sand);
            get_total_p();
        }

        

        public void сreate_present(int weight, int Candies, bool cac, bool mil, bool waf, bool san)
        {
            if (cac == true)
            {
                cacao cacao_sweet = new cacao(weight);
                cacao_sweet.price = 15;
                ListOfSweets.Add(cacao_sweet);
            }

            if (mil == true)
            {

                milk milk_sweet = new milk(weight);
                milk_sweet.price = 10;
                ListOfSweets.Add(milk_sweet);
            }

            if (waf == true)
            {
                wafle wafle_sweet = new wafle(weight);
                wafle_sweet.price = 8;
                ListOfSweets.Add(wafle_sweet);
            }

            if (san == true)
            {
                sand sand_sweet = new sand(weight);
                sand_sweet.price = 9;
                ListOfSweets.Add(sand_sweet);
            }
        }

        public void get_total_p()
        {
            foreach (var sweet in ListOfSweets)
            {
                total_price += sweet.price*sweet.number;
            }
        }

    }
}
